﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EBookStore.Users;
using EBookStore.Books;
using EBookStore.Orders;
using EBookStore.Payments;

namespace EBookStore.Management
{
    /// <summary>
    /// Singleton class
    /// hold representation of store 
    /// with all it's managers inside it
    /// </summary>
    public class BookStore
    {
        #region Managers Properties
        /// <summary>
        /// Orders Manager
        /// </summary>
        public Management.OrdersManager OrdersMgr
        {
            get { return Management.OrdersManager.Instance; }
        }


        /// <summary>
        /// Publisher's manager
        /// </summary>
        public Management.PublisherManager PublishersMgr
        {
            get { return Management.PublisherManager.Instance; }
        }

        /// <summary>
        /// Catalog manager
        /// </summary>
        public Books.Catalog CatalogMgr
        {
            get { return Books.Catalog.Instance; }
        }

        /// <summary>
        /// Users manager.
        /// </summary>
        public Management.UsersManager UsersMgr
        {
            get { return Management.UsersManager.Instance; }
        }
        
        #endregion


        #region Singleton


        private static BookStore _instance = null;
        private static object _syncObj = new object();

        /// <summary>
        /// BookStore instance
        /// </summary>
        public static BookStore Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (_syncObj)
                    {
                        if (_instance == null)
                        {
                            _instance = new BookStore();
                        }
                    }
                }
                return _instance;
            }
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        private BookStore()
        {

        } 
        #endregion
                  
    }
}
